package com.yuntian.controller;

import com.yuntian.entity.ProductMaster;
import com.yuntian.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ProductController {

    @Autowired
    private ProductService productService;

    /**
     * 前端调用的库存查询接口
     * 对应前端AJAX的url: /api/product/stock
     */
    @GetMapping("/api/product/stock")
    public ProductMaster queryStock(
            @RequestParam("shouhinCode") String shouhinCode  // 接收前端传递的商品コード
    ) {
        // 调用服务层查询商品信息（含在庫数）
        return productService.getProductByCode(shouhinCode);
    }







}